package com.jshcbd.mvp_kt_demo.utils

import android.content.Context
import android.widget.Toast

object ToastUtil {
    private var toast: Toast? = null
    fun showTextToast(context: Context?, msg: String?) {
        if (toast == null) {
            toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT)
        } else {
            toast!!.setText(msg)
        }
        toast!!.show()
    }

    fun showTextToastById(context: Context, msg: Int) {
        if (toast == null) {
            toast = Toast.makeText(context, context.resources.getString(msg), Toast.LENGTH_SHORT)
        } else {
            toast!!.setText(msg)
        }
        toast!!.show()
    }
}